﻿using System;
using UnityEngine;

// Token: 0x0200036C RID: 876
internal class SunController : MonoBehaviour
{
	// Token: 0x060016C2 RID: 5826 RVA: 0x00092C4C File Offset: 0x00090E4C
	public void Start()
	{
		this.prevMousePos = Input.mousePosition;
		this.Height = base.transform.position.y;
	}

	// Token: 0x060016C3 RID: 5827 RVA: 0x00092C80 File Offset: 0x00090E80
	public void Update()
	{
		Vector3 position = base.transform.position;
		position.y = this.Height;
		base.transform.position = position;
		if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1))
		{
			this.prevMousePos = Input.mousePosition;
		}
		Vector3 mousePosition = Input.mousePosition;
		Vector3 vector = mousePosition - this.prevMousePos;
		this.prevMousePos = mousePosition;
		if (Input.GetMouseButton(0))
		{
			this.DirLightTransform.Rotate(0f, vector.x * 0.1f, 0f, Space.World);
			this.DirLightTransform.Rotate(vector.y * 0.1f, 0f, 0f, Space.Self);
		}
		if (Input.GetMouseButton(1))
		{
			base.transform.Rotate(0f, vector.x * 0.1f, 0f, Space.World);
			base.transform.Rotate(-vector.y * 0.1f, 0f, 0f, Space.Self);
		}
		if (Input.GetKey(KeyCode.A))
		{
			this.Height += 2000f * Time.deltaTime;
		}
		if (Input.GetKey(KeyCode.Z))
		{
			this.Height -= 2000f * Time.deltaTime;
		}
		if (Input.GetKeyDown(KeyCode.BackQuote))
		{
			this.ShowHelp = !this.ShowHelp;
		}
	}

	// Token: 0x060016C4 RID: 5828 RVA: 0x00092DF4 File Offset: 0x00090FF4
	private void OnGUI()
	{
		if (this.ShowHelp)
		{
			GUILayout.Label("~ - Toggle help", new GUILayoutOption[0]);
			GUILayout.BeginHorizontal(new GUILayoutOption[0]);
			GUILayout.Label("Camera Height", new GUILayoutOption[]
			{
				GUILayout.ExpandWidth(false)
			});
			this.Height = GUILayout.HorizontalSlider(this.Height, 10f, 40000f, new GUILayoutOption[]
			{
				GUILayout.Width(400f)
			});
			GUILayout.EndHorizontal();
			GUILayout.Label("LMB - Rotate Sun", new GUILayoutOption[0]);
			GUILayout.Label("RMB - Rotate Camera", new GUILayoutOption[0]);
			GUILayout.Label("A/Z - Move Camera Up/Down", new GUILayoutOption[0]);
		}
	}

	// Token: 0x0400195F RID: 6495
	[Range(5f, 40000f)]
	public float Height = 5f;

	// Token: 0x04001960 RID: 6496
	public Transform DirLightTransform;

	// Token: 0x04001961 RID: 6497
	public bool ShowHelp = true;

	// Token: 0x04001962 RID: 6498
	private Vector3 prevMousePos;
}
